#ifndef HCELL_CHEMISTRY_INCLUDED
#define HCELL_CHEMISTRY_INCLUDED 1


#include "./vm.hpp"
#include "yocto/aqueous/initializer.hpp"

using namespace aqueous;


typedef functor<double,TL1(double)> SP_Function;

class Permeability
{
public:
    double      factor; //!< scaling, default is 1
    SP_Function SP;     //!< to load
    
    explicit Permeability( const SP_Function &sp );
    virtual ~Permeability() throw();
    
private:
    YOCTO_DISABLE_COPY_AND_ASSIGN(Permeability);
};



class Chemistry : public VM
{
public:
    
        
    const string     cfgpath;
    library          Library;
    chemsys          ChemSys;
    initializer      InitIn;
    initializer      InitOut;
    
    
    virtual ~Chemistry() throw();
    explicit Chemistry( const string &cfgname );
    
    solution & inside( double t);
    solution & outside( double t);
    
    void reload_inside( double t );
    
private:
    vector<solution> Solution;
    YOCTO_DISABLE_COPY_AND_ASSIGN(Chemistry);
    const SP_Function SP0;
    
    double NoPermeability( double ) const throw();
    void   LoadPermeability( species &s, lua_State *);
};

#endif
